//package gameam.Test;

import java.util.ArrayList;
import gameam.business.*;

import junit.framework.TestCase;

public class TestClass extends TestCase
{
	private MCBaseQuestion question;
	private MCBaseTest test;
	private MCAnswer answer;
	private ArrayList<MCAnswer> possibleAnswers;
    
	protected void setUp() 
	{ 
    	possibleAnswers = new ArrayList<MCAnswer>();
		answer = new MCAnswer(5,"A");
		possibleAnswers.add(answer);
		answer = new MCAnswer(3,"B");
		possibleAnswers.add(answer);
		answer = new MCAnswer(0,"C");
		possibleAnswers.add(answer);
		answer = new MCAnswer(-2,"D");
		possibleAnswers.add(answer);
		answer = new MCAnswer(-3,"E");
		possibleAnswers.add(answer);
		
		question = new MCBaseQuestion("test question", possibleAnswers);
		test = new MCBaseTest();
		test.AddQuestion(question);
  	}
	
	public void testMaxMarkForQuestion() 
	{ 	
	    assertEquals(question.MaxMarkForQuestion(), 8); 
	}
	
	public void testMinMarkForQuestion() 
	{ 
        assertEquals(question.MinMarkForQuestion(), -5); 
	}
	
	public void testAddDuplicateAnswerToQuestion()
	{
		question.AddAnswer(answer);
		assertEquals(question.MaxMarkForQuestion(), 8); 
		assertEquals(question.MinMarkForQuestion(), -5); 
	}
	
	public void testMaxMarkForTest()
	{
		 assertEquals(test.MaxMarkForTest(), 8);
	}
	
	public void testMinMarkForTest() 
	{ 
        assertEquals(test.MinMarkForTest(), -5); 
	}
	
	public void testAddDuplicateQuestionToTest()
	{
		test.AddQuestion(question);
		assertEquals(test.MaxMarkForTest(), 8);
		assertEquals(test.MinMarkForTest(), -5); 
	}
	
	public void testRemoveExistingQuestionFromTest()
	{
		test.RemoveQuestion(question);
		assertEquals(test.MaxMarkForTest(), 0);
		assertEquals(test.MinMarkForTest(), 0);
		test.AddQuestion(question);
	}
	
	public void testRemoveNonExistingQuestionFromTest()
	{
		answer = new MCAnswer(2,"Not existant");
		MCBaseQuestion q = new MCBaseQuestion("How many test cases should I make?");
		q.AddAnswer(answer);
		test.RemoveQuestion(q);
		assertEquals(test.MaxMarkForTest(), 8);
		assertEquals(test.MinMarkForTest(), -5); 
	}
	
	public void testRemoveExistingAnswerFromQuestion()
	{
		question.RemoveAnswer(answer);
		assertEquals(question.MaxMarkForQuestion(), 8); 
		assertEquals(question.MinMarkForQuestion(), -2);
	}
	
	public void testRemoveNonExistingAnswerFromQuestion()
	{
		answer = new MCAnswer(2,"Not existant");
		question.RemoveAnswer(answer);
		assertEquals(question.MaxMarkForQuestion(), 8); 
		assertEquals(question.MinMarkForQuestion(), -5);
	}
}    
